﻿namespace use_wasd_to_control_the_position
{   /// <summary>
/// use "wasd" to control the position
/// </summary>
    internal class Program
    {
        static void Main(string[] args)
        {            
            Console.Write("Hello, World!");
            int row = 0;
            int column = 0;                         //设置行和列
            char move;
            do                                      //不断输入wasd的循环
            {
                move = Console.ReadKey().KeyChar;   //输入一个字符，但不用输入回车
                switch (move)
                {
                    case 'a':
                        column--;
                        Console.Clear();
                        Console.SetCursorPosition(column, row);
                        Console.Write("Hello, World!");
                        break;
                    case 'd':
                        column++;
                        Console.Clear();
                        Console.SetCursorPosition(column, row);
                        Console.Write("Hello, World!");
                        break;
                    case 'w':
                        row--;
                        Console.Clear();
                        Console.SetCursorPosition(column, row);
                        Console.Write("Hello, World!");
                        break;
                    case 's':
                        row++;
                        Console.Clear();
                        Console.SetCursorPosition(column, row);
                        Console.Write("Hello, World!");
                        break;
                    default:                        //输入除wasd以外的字符——退出
                        move = 'q';
                        break;

                }
            } while (move!='q'&&row<50&&column<50);
          
        }
    }
}